package com.shop.util;
import com.shop.entity.Result;
/**
 * description: 该文件说明
 *
 * @author zhaoxiaozhao（xiaozhao.zhao@ucarinc.com）
 * @version 1.0
 * @date 2018/10/9 14:24
 **/
public class ResultUtil {

    public static int SUCCESS = 1;
    public static int ERROR = 0;

    public static Result success(Object object) {
        Result result = new Result();
        result.setData(object);
        result.setCode(SUCCESS);
        result.setMsg("成功");
        return result;
    }
    public static Result error(Object object) {
        Result result = new Result();
        result.setData(object);
        result.setCode(ERROR);
        result.setMsg("失败");
        return result;
    }

    public static Result error(String msg) {
        Result result = new Result();
        result.setCode(ERROR);
        result.setMsg(msg);
        return result;
    }

    public static Result success(String msg) {
        Result result = new Result();
        result.setCode(SUCCESS);
        result.setMsg(msg);
        return result;
    }
    public static Result success() {
        return success(null);
    }

    public static Result success(Integer code, String msg) {
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }

    public static Result error(Integer code, String msg) {
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }
}
